﻿<Window x:Class="ZuggerWpf.Option"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ZuggerWpf"
    Title="Zugger - 配置" SizeToContent="WidthAndHeight"
    WindowStyle="None"
    Loaded="Window_Loaded"
    Activated="Window_Activated"
    Background="{x:Null}"
    AllowsTransparency="True"
    ResizeMode="NoResize"
    FontFamily="微软雅黑"
    ShowInTaskbar="False"
    MouseLeftButtonDown="Window_MouseLeftButtonDown" Icon="/Zugger;component/zugger.ico" Width="321.2">
    <Window.Resources>
        <ResourceDictionary>
            <local:Count2Visible x:Key="count2vis"/>

            <LinearGradientBrush x:Key="shinyBrush" StartPoint="0,0" EndPoint="0,1">
                <GradientStop Offset="0" Color="Snow"/>
                <GradientStop Offset="0.5" Color="Gray"/>
                <GradientStop Offset="1" Color="Snow"/>
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="bg" StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="LightGray" Offset="0.5"/>
                <GradientStop Color="DarkGray" Offset="1"/>
            </LinearGradientBrush>
            <ControlTemplate x:Key="validationTemplate">
                <DockPanel>
                    <TextBlock Foreground="Red" FontSize="20">!</TextBlock>
                    <AdornedElementPlaceholder/>
                </DockPanel>
            </ControlTemplate>

            <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
                <Style.Triggers>
                    <Trigger Property="Validation.HasError" Value="true">
                        <Setter Property="ToolTip"
              Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                              Path=(Validation.Errors)[0].ErrorContent}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>

    </Window.Resources>
    <Border CornerRadius="8">
        <Border.Background>
            <StaticResourceExtension ResourceKey="bg" />
        </Border.Background>
        <Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="0" Text="查询间隔（分钟）：" TextAlignment="Right"/>
            <TextBox Name="txtInterval" Grid.Row="0" Grid.Column="1" Margin="2"
                 Validation.ErrorTemplate="{StaticResource validationTemplate}"
                Style="{StaticResource textBoxInError}"
                 KeyDown="txtInterval_KeyDown"
                 TextChanged="txtInterval_TextChanged">
                <TextBox.Text>
                    <Binding Path="RequestInterval"
                 UpdateSourceTrigger="PropertyChanged">
                        <Binding.ValidationRules>
                            <local:MinuteRule Min="1" Max="60"/>
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox.Text>
            </TextBox>

            <TextBlock Grid.Row="1" Grid.Column="0" Text="PMS地址：" TextAlignment="Right"/>
            <TextBox Name="txtPMSUrl" MinWidth="100" Grid.Row="1" Grid.Column="1" Margin="2"
                 Text="{Binding PMSHost}"/>

            <TextBlock Grid.Row="2" Grid.Column="0" Text="用户名：" TextAlignment="Right"/>
            <TextBox Name="txtUser" MinWidth="100" Grid.Row="2" Grid.Column="1" Margin="2"
                 Text="{Binding UserName}"/>

            <TextBlock Grid.Row="3" Grid.Column="0" Text="密码：" TextAlignment="Right"/>
            <PasswordBox Name="txtPwd" PasswordChar="●" MinWidth="100" Grid.Row="3" Grid.Column="1" Margin="2"/>          
            
            <GroupBox Grid.Row="4" Grid.ColumnSpan="2" Margin="5" Visibility="Collapsed">
                <GroupBox.Header>
                    <Label Content="PMS访问方式" Background="WhiteSmoke" FontStyle="Italic" ToolTip="关于PMS访问方式请咨询管理员"/>
                </GroupBox.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="105*" />
                        <ColumnDefinition Width="27.6*" />
                        <ColumnDefinition Width="133*" />
                    </Grid.ColumnDefinitions>
                    <RadioButton Name="ckget" Margin="5,5,4.8,5" Checked="ckget_Checked" Content="GET" Grid.ColumnSpan="2" />
                    <RadioButton Name="ckpi" Margin="5" Checked="ckpi_Checked" Content="PATH_INFO" Grid.Column="2"/>
                </Grid>
            </GroupBox>

            <Label Name="lbConnStatus" Grid.Row="5" Grid.Column="0" Foreground="Red" Content="登录失败" Margin="5" Visibility="Hidden"/>
            <Button Name="btnCheckCon" Margin="5" Grid.Row="5" Grid.Column="1" Background="{StaticResource shinyBrush}" Click="btnCheckCon_Click">测试连接</Button>

            <GroupBox Name="gbchooseMode" Grid.Row="6" Grid.ColumnSpan="2" Margin="5" >
                <GroupBox.Header>
                    <StackPanel Orientation="Horizontal">                        
                        <Label Name="chooseModeTip" Content="请至少选择一种显示方式" Foreground="Red" Visibility="Collapsed"/>
                    </StackPanel>
                </GroupBox.Header>
                <StackPanel Name="pnDispalyMode" Orientation="Horizontal">
                    <CheckBox Name="ckOpenedByMe" Margin="5" Content="我开的Bug" IsChecked="{Binding ShowOpendByMe}" Click="DisplayCheckBox_Click"/>
                    <CheckBox Name="ckBug" Margin="5" Content="给我的Bug" IsChecked="{Binding ShowBug}" Click="DisplayCheckBox_Click"/>
                    <CheckBox Name="ckTask" Margin="5" Content="任务" IsChecked="{Binding ShowTask}" Click="DisplayCheckBox_Click"/>
                    <CheckBox Name="ckStory" Margin="5" Content="需求" IsChecked="{Binding ShowStory}" Click="DisplayCheckBox_Click"/>
                </StackPanel>

            </GroupBox>
            <CheckBox Name="ckAutoRun" Grid.Row="7" Grid.ColumnSpan="2" Margin="5" IsChecked="{Binding IsAutoRun}" Content="开机时启动"/>
            <CheckBox Name="ckTaskNotify" Grid.Row="8" Grid.ColumnSpan="2" Margin="5" IsChecked="{Binding IsTaskNotify}" Content="显示任务栏消息提示"/>

            <Button Name="btnYes" Content="确定" Grid.Row="9" Grid.Column="0" Margin="2" Background="{StaticResource shinyBrush}" Click="btnYes_Click"/>
            <Button Name="btnNo"  Content="取消" Grid.Row="9" Grid.Column="1" Margin="2" Background="{StaticResource shinyBrush}" Click="btnNo_Click" IsCancel="True"/>
        </Grid>
    </Border>
</Window>
